.TH std::experimental::default_searcher,std::experimental::make_default_searcher 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::experimental::default_searcher,std::experimental::make_default_searcher \- std::experimental::default_searcher,std::experimental::make_default_searcher

.SH Synopsis
   Defined in header <experimental/functional>
   template< class ForwardIterator1, class BinaryPredicate =
   std::equal_to<> >                                          (library fundamentals TS)
   class default_searcher;

   A class suitable for use with std::experimental::search that delegates the search
   operation to the standard library's std::search.

   default_searcher is CopyConstructible and CopyAssignable.

.SH Member functions

std::experimental::default_searcher::default_searcher

   default_searcher( ForwardIterator pat_first,

                     ForwardIterator pat_last,

                     BinaryPredicate pred = BinaryPredicate() );

   Constructs a default_searcher by storing copies of pat_first, pat_last, and pred.

.SH Parameters

   pat_first, pat_last - a pair of iterators designating the string to be searched for
   pred                - a callable object used to determine equality

.SH Exceptions

   Any exceptions thrown by the copy constructors of BinaryPredicate or
   ForwardIterator.

std::experimental::default_searcher::operator()

   template< class ForwardIterator2 >
   ForwardIterator2 operator()( ForwardIterator2 first, ForwardIterator2  \fI(until C++17)\fP
   last ) const;
   template< class ForwardIterator2 >

   std::pair<ForwardIterator2, ForwardIterator2>                          \fI(since C++17)\fP

       operator()( ForwardIterator2 first, ForwardIterator2 last )
   const;

   The member function called by std::experimental::search to perform a search with
   this searcher.

   Equivalent to std::search(first, last, pat_first, pat_last, pred);.    \fI(until C++17)\fP
   Returns a pair of iterators i, j, where i is std::search(first, last,
   pat_first, pat_last, pred) and j is std::next(i,                       \fI(until C++17)\fP
   std::distance(pat_first, pat_last)) unless std::search returned last
   (no match), in which case j equals last as well.

.SH Parameters

   first, last - a pair of iterators designating the string to be examined

.SH Return value

   Iterator to the first position in [first, last) where a subsequence
   that compares equal to [pat_first, pat_last) as defined by pred is     \fI(until C++17)\fP
   located, or a copy of last otherwise.
   A pair of iterators to the first and one past last positions in
   [first, last) where a subsequence that compares equal to               \fI(since C++17)\fP
   [pat_first, pat_last) as defined by pred is located, or a pair of
   copies of last otherwise.

   Helper Functions

   template< class ForwardIterator, class BinaryPredicate =
   std::equal_to<> >

   default_searcher<ForwardIterator, BinaryPredicate>             (library fundamentals
   make_default_searcher(                                         TS)
       ForwardIterator pat_first,
       ForwardIterator pat_last,

       BinaryPredicate pred = BinaryPredicate());

   Helper function that constructs a std::experimental::default_searcher using template
   argument deduction. Equivalent to return default_searcher<ForwardIterator,
   BinaryPredicate>(pat_first, pat_last, pred);

.SH Parameters

   pat_first, pat_last - a pair of iterators designating the string to be searched for
   pred                - a callable object used to determine equality

.SH Return value

   A default_searcher constructed with the arguments pat_first, pat_last, pred.

.SH Example


// Run this code

 #include <experimental/algorithm>
 #include <experimental/functional>
 #include <iostream>
 #include <string>

 int main()
 {
     std::string in = "Lorem ipsum dolor sit amet, consectetur adipiscing elit,"
                      " sed do eiusmod tempor incididunt ut labore et dolore magna aliqua";
     std::string needle = "pisci";
     auto it = std::experimental::search(in.begin(), in.end(),
                   std::experimental::make_default_searcher(
                       needle.begin(), needle.end()));
     if (it != in.end())
         std::cout << "The string " << needle << " found at offset "
                   << it - in.begin() << '\\n';
     else
         std::cout << "The string " << needle << " not found\\n";
 }

.SH Output:

 The string pisci found at offset 43

.SH See also

   search searches for a range of elements
          \fI(function template)\fP

.SH Category:
     * Noindexed pages
